package com.xyzwps.paimon.furina.common.value

import com.xyzwps.paimon.furina.common.AppErrorCode
import com.xyzwps.paimon.furina.common.AppException
import io.swagger.v3.oas.annotations.media.Schema

@Schema(type = "string", example = "14212341234", description = "手机号")
data class Phone(override val value: String) : StringValue {
    init {
        if (!PHONE_PATTERN.matcher(value).matches()) {
            throw AppException(AppErrorCode.PHONE_FORMAT_INVALID, "手机号格式不正确")
        }
    }
}
